package cn.javazd.udp;

import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;

public class UdpSender {

	public static void main(String[] args) {
		try {
			DatagramSocket datagramSocket = new DatagramSocket();
			long startTime = System.currentTimeMillis();
			System.out.println("start send: ");

			String data = "this is send demo";

			DatagramPacket datagramPacket = new DatagramPacket(data.getBytes(), data.length(),
					InetAddress.getLocalHost(), 9090);

			datagramSocket.send(datagramPacket);
			System.out.println("end send times: " + (System.currentTimeMillis() - startTime));
			datagramSocket.close();

		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}
